package main

import (
	"bytes"
	"io"
	"mime/multipart"
	"net/http"
	"os"
)

func main() {
	// 定义内存中的切片
	buffer := bytes.NewBuffer(nil)

	// 定义multipartwriter对象
	writer := multipart.NewWriter(buffer)

	// 创建上传的文件
	filewriter, _ := writer.CreateFormFile("file", "a.json")

	// 打开上传的文件
	f, _ := os.Open("a.json")

	// 将文件内容拷贝到filewriter对象中
	io.Copy(filewriter, f)
	writer.Close()
	response, _ := http.Post("http://127.0.0.1:9999", "multipart/form-data", buffer)
	io.Copy(os.Stdout, response.Body)

}
